package com.deng.framework.context.event;

import com.deng.framework.beans.factory.BeanFactory;
import com.deng.framework.context.ApplicationEvent;
import com.deng.framework.context.ApplicationListener;

/**
 * 对外的事件广播类，是最终的实现类
 */
public class SimpleApplicationEventMulticaster extends AbstractApplicationEventMulticaster{
    public SimpleApplicationEventMulticaster(BeanFactory beanFactory) {
        setBeanFactory(beanFactory);
    }

    @Override
    public void multicastEvent(final ApplicationEvent event) {
        for(final ApplicationListener listener : getApplicationListeners(event)){
            //对所有感兴趣的listener运行其自定义处理函数
            listener.onApplicationEvent(event);
        }
    }
}
